package com.bwie.controller;

import com.bwie.service.EventsService;
import com.bwie.utils.R;
import com.bwie.vo.EsEvents;
import com.bwie.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Title:
 * @BelongProjecet zk2
 * @BelongPackage com.bwie.controller
 * @Description:
 * @Copyright 研发一部
 * @Author: Mr.yan
 * @Date: 2024/6/3 9:19
 * @Version V1.0
 */
@RestController
@RequestMapping("/events/events")
public class EventsController {

    @Autowired
    private EventsService eventsService;

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/3 9:32
     * @param: 创建索引和映射
     * @return com.bwie.utils.R
     */
    @PostMapping("/createIndex")
    public R createIndex(){
        return eventsService.createIndex();
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/3 9:52
     * @param: 分页+高亮+模糊查询
     * @param pageVo
     * @return com.bwie.utils.R
     */
    @PostMapping("/eventsList")
    public R eventsList(
            @RequestBody PageVo pageVo
            ){
        return eventsService.eventsList(pageVo);
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/3 9:53
     * @param: 添加数据
     * @param esEvents
     * @return null
     */
    public R addEvents(
            @RequestBody EsEvents esEvents
            ){
        return eventsService.addEvents(esEvents);
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/3 10:13
     * @param: 上传图片
     * @param file
     * @return null
     */
    @PostMapping("/uploadFile")
    public R uploadFile(
            @RequestPart(name = "file")MultipartFile file
            ){
        return eventsService.uploadFile(file);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/3 20:58
     * @param: 上传视频
     * @param file
     * @return com.bwie.utils.R
     */
    @PostMapping("/uploadVideo")
    public R uploadVideo(
            @RequestPart(name = "file")MultipartFile file
    ){
        return eventsService.uploadVideo(file);
    }
}
